#include <iostream>
#include <string>
using namespace std;

int main()
{
    string v;
    cout << "entering a value: ";
    getline(cin, v);
    for (int o = 0; o < v.size(); o++)
    {
        if (v[o] != '(' && v[o] != ')' && v[o] != '{' && v[o] != '}' && v[o] != '[' && v[o] != ']' && v[o] != '<' && v[o] != '>')
        {
            v.erase(o,1);
            o--;
        }
    }
    
    if (v.size() == 0 || v.size() % 2 != 0 )
    {
        cout << "false";
    }
    else
    {
        for (int i = 0; i < v.size(); i++)
        {
            if (v[i] == '{' && v[i + 1] == '}' ||
                v[i] == '(' && v[i + 1] == ')' ||
                v[i] == '[' && v[i + 1] == ']' ||
                v[i] == '<' && v[i + 1] == '>')
            {

                v.erase(i, 2);
                i -= 2;

                if (i < -1)
                {
                    i++;
                }
                
            }
        }
        if (v.size() == 0)
            cout << "true";
        else
            cout << "false";
    }
    return 0;
}
